pub mod agents;
use riir::*;

pub use agents::code2prompt::code2prompt;

use std::sync::Arc;
use tokio::sync::Mutex;
use crate::agents::AgentAdmin;
use tracing::info;
use std::path::PathBuf;


pub async fn run(input: String, output_path: PathBuf) {
    let config = Arc::new(Config::load());

    let llm = Arc::new(Mutex::new(
        LLMModel::init(&config.llm, config.clone()).await,
    ));
    let llm = llm.clone();

    info!(" ---- Current Input: plain {:?}", input);


    // 占用本线程，会阻塞 UI
    tokio::task::block_in_place(move || {
        tokio::runtime::Handle::current().block_on(async move {
            let mut agent_admin: AgentAdmin = AgentAdmin::new(input, llm, output_path)
                .await
                .expect("Error creating agent");

            agent_admin.execute().await
        });
    })
}
